// locutor
// (c) 2009, Normen Müller, normen.mueller@gmail.com  
// $Id: D.scala 88 2010-05-11 21:56:49Z normen.mueller $
package locutor.draft.graphs

///** A dependency graph.
// * 
// * @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
// * @version 0.0.5 */
//class DependencyGraph private [locutor] (val name: String, val reference: File, val revision: Int, val model: GraphModel)
//  extends MultiGraph
//  with MultiGraph#NodeLabels[Map[String, String]]
//  with MultiGraph#EdgeLabels[Map[String, String]]
//  with MultiGraph#Directions {
//    
//    self: DependencyGraph =>
//    
//  // URL/XPath -> V
//  private val nodes = collection.mutable.HashMap.empty[String, V]
//  
//  def V = Set.empty[V] ++ nodes.values
//  
//  private var edges: List[E] = Nil
//  
//  def E = Set.empty[E] ++ edges
//  
//  //@todo check for duplicates
//  def + (id: String, url: URL, path: LocationPath, attributes: A) = {
//    val infom = Infom(id, url, path, attributes)
//    nodes += {( url.toString + path, infom )}
//    ids   += {( id, infom )}
//    this
//  }
//  
//  // Ident -> V
//  private val ids = collection.mutable.HashMap.empty[String, V] 
//  
//  def \ (id: String) = ids get id //V \? { case Infom(_, _, as) if as.get("$") == Some(id) => true }
//  
//  //@todo partial ordering of XPath1.0 expressions for identification of surrounding INFOM
//  def \ (path: LocationPath) = nodes get (reference.toURL.toString + path)
//  
//  import Rippler.{ripple}
//  
//  def ↩ (δ: List[Command]) = new {
//    def having(rules: RuleSystem) = δ match {
//      case Nil => Map.empty[Command, ImpactGraph]
//      case _   => ripple(δ) withKnowledgeBase (self, rules) 
//    }      
//  } 
//  
//  type A = Map[String, String]
//    
//  type V = Infom
//  
//  private [DependencyGraph] case class Infom(val id: String, val url: URL, val path: LocationPath, val label: A) extends Node { self: V =>
//    def ->(v: V): E = (this connectTo v)(Map())
//    def connectTo(v: V)(attributes: A): E = {
//      val d = Dependency(this, v, attributes)
//      edges ::= d
//      d
//    } 
//    
//    def inDegree = incoming.size
//    def incoming = E filter {case Dependency(_, target, _) if target == this => true case _ => false}
//      
//    def outDegree = outgoing.size
//    def outgoing  = E filter {case Dependency(source, _, _) if source == this => true case _ => false}
//        
//    def degree = inDegree + outDegree
//    
//    override def toString = {
//      val buf = new StringBuilder
//      buf append id append ":" append label("type") append "("
//      
//      buf append "url=\"" + url + "\"," append "xpath=\"" + path + "\""
//      
//      val elems = (label - "type").keys
//      if (elems.hasNext) {
//        val elem = elems.next
//        buf append "," append elem append "=" append label(elem)
//      }
//      while (elems.hasNext) {
//        val elem = elems.next
//        buf append ","
//        buf append elem append "=" append label(elem)
//      }      
//
//      buf append ")"
//      buf.toString
//    }
//  }
//  
//  type E = Dependency
//  
//  private [DependencyGraph] case class Dependency(val source: V, val target: V, label: A) extends Edge {
//    override def toString = {
//      val buf = new StringBuilder
//      buf append source.id append " -:" append label("type") append "("
//      
//      val elems = (label - "type").keys
//      if (elems.hasNext) {
//        val elem = elems.next
//        buf append elem append "=" append label(elem)
//      }
//      while (elems.hasNext) {
//        val elem = elems.next
//        buf append ","
//        buf append elem append "=" append label(elem)
//      }      
//
//      buf append ")" append "-> " append target.id
//      buf.toString
//    }
//  }
//  
//}
